<?php
class info_rekap_koin_dropzone extends MY_Controller{
    var $data;
    function info_rekap_koin_dropzone(){
        parent::MY_Controller();
        $this->data['title'] = "Informasi Rekap Koin Per Dropzone";
        $this->load->model('m_rekap_koin_dropzone');
        $this->load->plugin('jpgraph'); 
    }
    function index(){
        $this->get_rekap_koin_dropzone('all');
    }
    function search(){
        $url = $this->input->post("url");
        $apply = $this->input->post("Apply");
        $awal = $this->input->post("awal");
        $akhir = $this->input->post("akhir");
        $dropzone = $this->input->post("dropzone");
        $id_dropzone = $this->input->post("id_dropzone");
        $params = "awal_".date2mysql($awal)."__akhir_".date2mysql($akhir)."__dropzone_".$dropzone."__idDropzone_".$id_dropzone."__Apply_".$apply;
        
        redirect("$url/$params");
    }
    function get_rekap_koin_dropzone($params = "all"){
        $option = parsing_param2($params);
        $this->data['content'] = "rekap_koin_dropzone/v_rekap_koin_dropzone";
        $this->data['formTitle'] = "Parameter Pencarian";
        $this->data['searchLink'] = "info_rekap_koin_dropzone/get_rekap_koin_dropzone";
        $this->data['listRekapKoinDropzone'] = $this->m_rekap_koin_dropzone->get_list_rekap_koin_dropzone($option);
        $content = $this->data['listRekapKoinDropzone'];
        if(count($content['master']) > 0){
            foreach ($content['master'] as $row){
                $ydata[] = $row['jumlah']/10000;
                $xdata[] = datefmysql($row['tanggal']);
            }
            $maxScale = ($content['max']/10000);
            $graph = linechart($maxScale,$ydata,$xdata,'Grafik Rekap Koin Dropzone','Periode','Jumlah (x10.000 Rp.)');
            $graph_temp_directory = 'temp';  
            $graph_file_name = 'rekap_koin_dropzone.png';
            $graph_file_location = $graph_temp_directory . '/' . $graph_file_name;
            if(file_exists($graph_file_location)){
                @unlink($graph_file_location);
            }
            $graph->Stroke('./'.$graph_file_location);
            $this->data['graph'] = $graph_file_location;
        }
        $this->render($this->data);
    }
}
?>
